# 0.0 Load data ----
source('src/initialize.r')

# 1.0 Tables ----
## 1.1 Table A1 ----
ds %>%
  select(
    partyr,
    gender,
    age,
    race,
    hispanic,
    education,
    income,
    parent
  ) %>%
  tbl_summary(
    missing = "no",
    label = c(
      partyr ~ "Party",
      gender ~ "Gender",
      age ~ "Age",
      race ~ "Race",
      hispanic ~ "Hispanic",
      education ~ "Education",
      income ~ "Income",
      parent ~ "Parent"
    )
  )

## 1.2 Table A2 ----
ds %>%
  select(
    partyr,
    gender,
    age,
    race,
    hispanic,
    education,
    income,
    parent,
    full_treatment
  ) %>%
  tbl_summary(
    by = full_treatment,
    missing = "no",
    label = c(
      partyr ~ "Party",
      gender ~ "Gender",
      age ~ "Age",
      race ~ "Race",
      hispanic ~ "Hispanic",
      education ~ "Education",
      income ~ "Income",
      parent ~ "Parent"
    )
  ) %>%
  add_p()

## 1.3 Table A3 ----
therm.anova <- aov(feeling_change ~ full_treatment, ds)
anova.therm.mod.results <- TukeyHSD(therm.anova, conf.level = .95)
anova.therm.mod.results$full_treatment

## 1.4 Table A4 ----
eff.anova <- aov(effective_change ~ full_treatment, ds)
anova.eff.mod.results <- TukeyHSD(eff.anova, conf.level = .95)
anova.eff.mod.results$full_treatment

## 1.5 Table A5 ----
rep.anova <- aov(represent_change ~ full_treatment, ds)
anova.rep.mod.results <- TukeyHSD(rep.anova, conf.level = .95)
anova.rep.mod.results$full_treatment

## 1.6 Table A6 ----
resp.anova <- aov(responsible_change ~ full_treatment, ds)
anova.resp.mod.results <- TukeyHSD(resp.anova, conf.level = .95)
anova.resp.mod.results$full_treatment

## 1.7 Table A7 ----
feel_mod <- lm(feeling_change ~ full_treatment, data = ds)
effect_mod <- lm(effective_change ~ full_treatment, data = ds)
rep_mod <- lm(represent_change ~ full_treatment, data = ds)
resp_mod <- lm(responsible_change ~ full_treatment, data = ds)

models <- list()
models[['Thermometer (0-100)']] <- feel_mod
models[['Effectiveness (0-10)']] <- effect_mod
models[['Representation (0-10)']] <- rep_mod
models[['Resposibility (0-10)']] <- resp_mod

coefs <- c(
  "full_treatmentAnnounce" = "Announce",
  "full_treatmentCredit_Claim" = "Credit Claim",
  "full_treatmentCommiserate" = "Commiserate",
  "full_treatmentProtect" = "Protect",
  "(Intercept)" = "Constant"
)

modelsummary(
  models,
  stars = c('*' = .05, '**' = .01, '***' = .001),
  coef_map = coefs,
  fmt = 2,
  title = '',
  gof_omit = 'R2 Adj.|Log.Lik.|F|AIC|BIC|RMSE',
  notes = "NOTE: Reference treatment = Control"
)

## 1.8 Table A8 ----
feel_mod_cov <- lm(
  feeling_change ~
    full_treatment +
      partyr +
      party_match +
      income +
      gender +
      region +
      age +
      education +
      ideo +
      black +
      hisplat +
      asam +
      natam +
      white +
      multiracial +
      rother +
      hispanic +
      parent,
  data = ds
)

effect_mod_cov <- lm(
  effective_change ~
    full_treatment +
      partyr +
      party_match +
      income +
      gender +
      region +
      age +
      education +
      ideo +
      black +
      hisplat +
      asam +
      natam +
      white +
      multiracial +
      rother +
      hispanic +
      parent,
  data = ds
)

rep_mod_cov <- lm(
  represent_change ~
    full_treatment +
      partyr +
      party_match +
      income +
      gender +
      region +
      age +
      education +
      ideo +
      black +
      hisplat +
      asam +
      natam +
      white +
      multiracial +
      rother +
      hispanic +
      parent,
  data = ds
)

resp_mod_cov <- lm(
  responsible_change ~
    full_treatment +
      partyr +
      party_match +
      income +
      gender +
      region +
      age +
      education +
      ideo +
      black +
      hisplat +
      asam +
      natam +
      white +
      multiracial +
      rother +
      hispanic +
      parent,
  data = ds
)

models_cov <- list()
models_cov[['Thermometer (0-100)']] <- feel_mod_cov
models_cov[['Effectiveness (0-10)']] <- effect_mod_cov
models_cov[['Representation (0-10)']] <- rep_mod_cov
models_cov[['Resposibility (0-10)']] <- resp_mod_cov

coefs_cov <- c(
  "full_treatmentAnnounce" = "Announce",
  "full_treatmentCredit_Claim" = "Credit Claim",
  "full_treatmentCommiserate" = "Commiserate",
  "full_treatmentProtect" = "Protect",
  "partyrrep" = "Resp. Party: Rep.",
  "partyrind" = "Resp. Party: Ind.",
  "party_match" = "Partisan Match",
  "income" = "Income",
  "genderwoman" = "Resp. Gender: Woman",
  "regionNortheast" = "Region: Northeast",
  "regionSouth" = "Region: South",
  "regionWest" = "Region: West",
  "age" = "Age",
  "educationLess_than_Bachelors" = "Education: Less than Bachelors",
  "ideo" = "Ideology",
  "black" = "Race: Black",
  "hisplat" = "Race: Latino",
  "asam" = "Race: Asian",
  "natam" = "Race: Native American",
  "white" = "Race: White",
  "multiracial" = "Race: More than one race",
  "rother" = "Race: Other",
  "hispanic" = "Hispanic",
  "parentYes" = "Parent",
  "(Intercept)" = "Constant"
)

modelsummary(
  models_cov,
  estimate = "{estimate} ({std.error}){stars}",
  statistic = NULL,
  stars = c('*' = .05, '**' = .01, '***' = .001),
  coef_map = coefs_cov,
  fmt = 2,
  title = '',
  gof_omit = 'R2 Adj.|Log.Lik.|F|AIC|BIC|RMSE',
  notes = "NOTE: Reference treatment = Control"
)

## 1.9 Table A9 ----
t.test.h1.therm_d <- t.test(
  ds$feeling_change[ds$full_treatment == 'Protect' & ds$partytwo == "dem"],
  ds$feeling_change[ds$full_treatment == 'Credit_Claim' & ds$partytwo == "dem"]
)
t.test.h1.eff_d <- t.test(
  ds$effective_change[ds$full_treatment == 'Protect' & ds$partytwo == "dem"],
  ds$effective_change[
    ds$full_treatment == 'Credit_Claim' & ds$partytwo == "dem"
  ]
)
t.test.h1.rep_d <- t.test(
  ds$represent_change[ds$full_treatment == 'Protect' & ds$partytwo == "dem"],
  ds$represent_change[
    ds$full_treatment == 'Credit_Claim' & ds$partytwo == "dem"
  ]
)
t.test.h1.resp_d <- t.test(
  ds$responsible_change[ds$full_treatment == 'Protect' & ds$partytwo == "dem"],
  ds$responsible_change[
    ds$full_treatment == 'Credit_Claim' & ds$partytwo == "dem"
  ]
)

data.frame(
  "DV" = c(
    "Feeling Therm. Rating (0-100) Change",
    "Effectiveness Rating (0-10) Change",
    "Representation Rating (0-10) Change",
    "Responsibility Rating (0-10) Change"
  ),
  "Credit Claim" = c(
    t.test.h1.therm_d$estimate[[2]],
    t.test.h1.eff_d$estimate[[2]],
    t.test.h1.rep_d$estimate[[2]],
    t.test.h1.resp_d$estimate[[2]]
  ),
  "Protect" = c(
    t.test.h1.therm_d$estimate[[1]],
    t.test.h1.eff_d$estimate[[1]],
    t.test.h1.rep_d$estimate[[1]],
    t.test.h1.resp_d$estimate[[1]]
  ),
  "Diff in Means" = c(
    t.test.h1.therm_d$estimate[[1]] - t.test.h1.therm_d$estimate[[2]],
    t.test.h1.eff_d$estimate[[1]] - t.test.h1.eff_d$estimate[[2]],
    t.test.h1.rep_d$estimate[[1]] - t.test.h1.rep_d$estimate[[2]],
    t.test.h1.resp_d$estimate[[1]] - t.test.h1.resp_d$estimate[[2]]
  ),
  "p.value" = c(
    t.test.h1.therm_d$p.value,
    t.test.h1.eff_d$p.value,
    t.test.h1.rep_d$p.value,
    t.test.h1.resp_d$p.value
  )
)

## 1.10 Table A10 ----
t.test.h2.therm_d <- t.test(
  ds$feeling_change[ds$full_treatment == 'Commiserate' & ds$partytwo == "dem"],
  ds$feeling_change[ds$full_treatment == 'Control' & ds$partytwo == "dem"]
)
t.test.h2.eff_d <- t.test(
  ds$effective_change[
    ds$full_treatment == 'Commiserate' & ds$partytwo == "dem"
  ],
  ds$effective_change[ds$full_treatment == 'Control' & ds$partytwo == "dem"]
)
t.test.h2.rep_d <- t.test(
  ds$represent_change[
    ds$full_treatment == 'Commiserate' & ds$partytwo == "dem"
  ],
  ds$represent_change[ds$full_treatment == 'Control' & ds$partytwo == "dem"]
)
t.test.h2.resp_d <- t.test(
  ds$responsible_change[
    ds$full_treatment == 'Commiserate' & ds$partytwo == "dem"
  ],
  ds$responsible_change[ds$full_treatment == 'Control' & ds$partytwo == "dem"]
)

data.frame(
  "DV" = c(
    "Feeling Therm. Rating (0-100) Change",
    "Effectiveness Rating (0-10) Change",
    "Representation Rating (0-10) Change",
    "Responsibility Rating (0-10) Change"
  ),
  "Control" = c(
    t.test.h2.therm_d$estimate[[2]],
    t.test.h2.eff_d$estimate[[2]],
    t.test.h2.rep_d$estimate[[2]],
    t.test.h2.resp_d$estimate[[2]]
  ),
  "Commiserate" = c(
    t.test.h2.therm_d$estimate[[1]],
    t.test.h2.eff_d$estimate[[1]],
    t.test.h2.rep_d$estimate[[1]],
    t.test.h2.resp_d$estimate[[1]]
  ),
  "Diff in Means" = c(
    t.test.h2.therm_d$estimate[[1]] - t.test.h2.therm_d$estimate[[2]],
    t.test.h2.eff_d$estimate[[1]] - t.test.h2.eff_d$estimate[[2]],
    t.test.h2.rep_d$estimate[[1]] - t.test.h2.rep_d$estimate[[2]],
    t.test.h2.resp_d$estimate[[1]] - t.test.h2.resp_d$estimate[[2]]
  ),
  "p.value" = c(
    t.test.h2.therm_d$p.value,
    t.test.h2.eff_d$p.value,
    t.test.h2.rep_d$p.value,
    t.test.h2.resp_d$p.value
  )
)

## 1.11 Table A11 ----
t.test.h1.therm_r <- t.test(
  ds$feeling_change[ds$full_treatment == 'Protect' & ds$partytwo == "rep"],
  ds$feeling_change[ds$full_treatment == 'Credit_Claim' & ds$partytwo == "rep"]
)
t.test.h1.eff_r <- t.test(
  ds$effective_change[ds$full_treatment == 'Protect' & ds$partytwo == "rep"],
  ds$effective_change[
    ds$full_treatment == 'Credit_Claim' & ds$partytwo == "rep"
  ]
)
t.test.h1.rep_r <- t.test(
  ds$represent_change[ds$full_treatment == 'Protect' & ds$partytwo == "rep"],
  ds$represent_change[
    ds$full_treatment == 'Credit_Claim' & ds$partytwo == "rep"
  ]
)
t.test.h1.resp_r <- t.test(
  ds$responsible_change[ds$full_treatment == 'Protect' & ds$partytwo == "rep"],
  ds$responsible_change[
    ds$full_treatment == 'Credit_Claim' & ds$partytwo == "rep"
  ]
)

data.frame(
  "DV" = c(
    "Feeling Therm. Rating (0-100) Change",
    "Effectiveness Rating (0-10) Change",
    "Representation Rating (0-10) Change",
    "Responsibility Rating (0-10) Change"
  ),
  "Credit Claim" = c(
    t.test.h1.therm_r$estimate[[2]],
    t.test.h1.eff_r$estimate[[2]],
    t.test.h1.rep_r$estimate[[2]],
    t.test.h1.resp_r$estimate[[2]]
  ),
  "Protect" = c(
    t.test.h1.therm_r$estimate[[1]],
    t.test.h1.eff_r$estimate[[1]],
    t.test.h1.rep_r$estimate[[1]],
    t.test.h1.resp_r$estimate[[1]]
  ),
  "Diff in Means" = c(
    t.test.h1.therm_r$estimate[[1]] - t.test.h1.therm_r$estimate[[2]],
    t.test.h1.eff_r$estimate[[1]] - t.test.h1.eff_r$estimate[[2]],
    t.test.h1.rep_r$estimate[[1]] - t.test.h1.rep_r$estimate[[2]],
    t.test.h1.resp_r$estimate[[1]] - t.test.h1.resp_r$estimate[[2]]
  ),
  "p.value" = c(
    t.test.h1.therm_r$p.value,
    t.test.h1.eff_r$p.value,
    t.test.h1.rep_r$p.value,
    t.test.h1.resp_r$p.value
  )
)

## 1.12 Table A12 ----
t.test.h2.therm_r <- t.test(
  ds$feeling_change[ds$full_treatment == 'Commiserate' & ds$partytwo == "rep"],
  ds$feeling_change[ds$full_treatment == 'Control' & ds$partytwo == "rep"]
)
t.test.h2.eff_r <- t.test(
  ds$effective_change[
    ds$full_treatment == 'Commiserate' & ds$partytwo == "rep"
  ],
  ds$effective_change[ds$full_treatment == 'Control' & ds$partytwo == "rep"]
)
t.test.h2.rep_r <- t.test(
  ds$represent_change[
    ds$full_treatment == 'Commiserate' & ds$partytwo == "rep"
  ],
  ds$represent_change[ds$full_treatment == 'Control' & ds$partytwo == "rep"]
)
t.test.h2.resp_r <- t.test(
  ds$responsible_change[
    ds$full_treatment == 'Commiserate' & ds$partytwo == "rep"
  ],
  ds$responsible_change[ds$full_treatment == 'Control' & ds$partytwo == "rep"]
)

data.frame(
  "DV" = c(
    "Feeling Therm. Rating (0-100) Change",
    "Effectiveness Rating (0-10) Change",
    "Representation Rating (0-10) Change",
    "Responsibility Rating (0-10) Change"
  ),
  "Control" = c(
    t.test.h2.therm_r$estimate[[2]],
    t.test.h2.eff_r$estimate[[2]],
    t.test.h2.rep_r$estimate[[2]],
    t.test.h2.resp_r$estimate[[2]]
  ),
  "Commiserate" = c(
    t.test.h2.therm_r$estimate[[1]],
    t.test.h2.eff_r$estimate[[1]],
    t.test.h2.rep_r$estimate[[1]],
    t.test.h2.resp_r$estimate[[1]]
  ),
  "Diff in Means" = c(
    t.test.h2.therm_r$estimate[[1]] - t.test.h2.therm_r$estimate[[2]],
    t.test.h2.eff_r$estimate[[1]] - t.test.h2.eff_r$estimate[[2]],
    t.test.h2.rep_r$estimate[[1]] - t.test.h2.rep_r$estimate[[2]],
    t.test.h2.resp_r$estimate[[1]] - t.test.h2.resp_r$estimate[[2]]
  ),
  "p.value" = c(
    t.test.h2.therm_r$p.value,
    t.test.h2.eff_r$p.value,
    t.test.h2.rep_r$p.value,
    t.test.h2.resp_r$p.value
  )
)

## 1.13 Table A13 ----
sd.h1.therm <- t.test(
  ds$feeling_change[ds$full_treatment == 'Protect' & ds$party_sen == "dem"],
  ds$feeling_change[ds$full_treatment == 'Credit_Claim' & ds$party_sen == "dem"]
)
sd.h1.eff <- t.test(
  ds$effective_change[ds$full_treatment == 'Protect' & ds$party_sen == "dem"],
  ds$effective_change[
    ds$full_treatment == 'Credit_Claim' & ds$party_sen == "dem"
  ]
)
sd.h1.rep <- t.test(
  ds$represent_change[ds$full_treatment == 'Protect' & ds$party_sen == "dem"],
  ds$represent_change[
    ds$full_treatment == 'Credit_Claim' & ds$party_sen == "dem"
  ]
)
sd.h1.resp <- t.test(
  ds$responsible_change[ds$full_treatment == 'Protect' & ds$party_sen == "dem"],
  ds$responsible_change[
    ds$full_treatment == 'Credit_Claim' & ds$party_sen == "dem"
  ]
)

data.frame(
  "DV" = c(
    "Feeling Therm. Rating (0-100) Change",
    "Effectiveness Rating (0-10) Change",
    "Representation Rating (0-10) Change",
    "Responsibility Rating (0-10) Change"
  ),
  "Credit Claim" = c(
    sd.h1.therm$estimate[[2]],
    sd.h1.eff$estimate[[2]],
    sd.h1.rep$estimate[[2]],
    sd.h1.resp$estimate[[2]]
  ),
  "Protect" = c(
    sd.h1.therm$estimate[[1]],
    sd.h1.eff$estimate[[1]],
    sd.h1.rep$estimate[[1]],
    sd.h1.resp$estimate[[1]]
  ),
  "Diff in Means" = c(
    sd.h1.therm$estimate[[1]] - sd.h1.therm$estimate[[2]],
    sd.h1.eff$estimate[[1]] - sd.h1.eff$estimate[[2]],
    sd.h1.rep$estimate[[1]] - sd.h1.rep$estimate[[2]],
    sd.h1.resp$estimate[[1]] - sd.h1.resp$estimate[[2]]
  ),
  "p.value" = c(
    sd.h1.therm$p.value,
    sd.h1.eff$p.value,
    sd.h1.rep$p.value,
    sd.h1.resp$p.value
  )
)

## 1.14 Table A14 ----
sd.h2.therm <- t.test(
  ds$feeling_change[ds$full_treatment == 'Commiserate' & ds$party_sen == "dem"],
  ds$feeling_change[ds$full_treatment == 'Control' & ds$party_sen == "dem"]
)
sd.h2.eff <- t.test(
  ds$effective_change[
    ds$full_treatment == 'Commiserate' & ds$party_sen == "dem"
  ],
  ds$effective_change[ds$full_treatment == 'Control' & ds$party_sen == "dem"]
)
sd.h2.rep <- t.test(
  ds$represent_change[
    ds$full_treatment == 'Commiserate' & ds$party_sen == "dem"
  ],
  ds$represent_change[ds$full_treatment == 'Control' & ds$party_sen == "dem"]
)
sd.h2.resp <- t.test(
  ds$responsible_change[
    ds$full_treatment == 'Commiserate' & ds$party_sen == "dem"
  ],
  ds$responsible_change[ds$full_treatment == 'Control' & ds$party_sen == "dem"]
)

data.frame(
  "DV" = c(
    "Feeling Therm. Rating (0-100) Change",
    "Effectiveness Rating (0-10) Change",
    "Representation Rating (0-10) Change",
    "Responsibility Rating (0-10) Change"
  ),
  "Control" = c(
    sd.h2.therm$estimate[[2]],
    sd.h2.eff$estimate[[2]],
    sd.h2.rep$estimate[[2]],
    sd.h2.resp$estimate[[2]]
  ),
  "Commiserate" = c(
    sd.h2.therm$estimate[[1]],
    sd.h2.eff$estimate[[1]],
    sd.h2.rep$estimate[[1]],
    sd.h2.resp$estimate[[1]]
  ),
  "Diff in Means" = c(
    sd.h2.therm$estimate[[1]] - sd.h2.therm$estimate[[2]],
    sd.h2.eff$estimate[[1]] - sd.h2.eff$estimate[[2]],
    sd.h2.rep$estimate[[1]] - sd.h2.rep$estimate[[2]],
    sd.h2.resp$estimate[[1]] - sd.h2.resp$estimate[[2]]
  ),
  "p.value" = c(
    sd.h2.therm$p.value,
    sd.h2.eff$p.value,
    sd.h2.rep$p.value,
    sd.h2.resp$p.value
  )
)

## 1.15 Table A15 ----
sr.h1.therm <- t.test(
  ds$feeling_change[ds$full_treatment == 'Protect' & ds$party_sen == "rep"],
  ds$feeling_change[ds$full_treatment == 'Credit_Claim' & ds$party_sen == "rep"]
)
sr.h1.eff <- t.test(
  ds$effective_change[ds$full_treatment == 'Protect' & ds$party_sen == "rep"],
  ds$effective_change[
    ds$full_treatment == 'Credit_Claim' & ds$party_sen == "rep"
  ]
)
sr.h1.rep <- t.test(
  ds$represent_change[ds$full_treatment == 'Protect' & ds$party_sen == "rep"],
  ds$represent_change[
    ds$full_treatment == 'Credit_Claim' & ds$party_sen == "rep"
  ]
)
sr.h1.resp <- t.test(
  ds$responsible_change[ds$full_treatment == 'Protect' & ds$party_sen == "rep"],
  ds$responsible_change[
    ds$full_treatment == 'Credit_Claim' & ds$party_sen == "rep"
  ]
)

data.frame(
  "DV" = c(
    "Feeling Therm. Rating (0-100) Change",
    "Effectiveness Rating (0-10) Change",
    "Representation Rating (0-10) Change",
    "Responsibility Rating (0-10) Change"
  ),
  "Credit Claim" = c(
    sr.h1.therm$estimate[[2]],
    sr.h1.eff$estimate[[2]],
    sr.h1.rep$estimate[[2]],
    sr.h1.resp$estimate[[2]]
  ),
  "Protect" = c(
    sr.h1.therm$estimate[[1]],
    sr.h1.eff$estimate[[1]],
    sr.h1.rep$estimate[[1]],
    sr.h1.resp$estimate[[1]]
  ),
  "Diff in Means" = c(
    sr.h1.therm$estimate[[1]] - sr.h1.therm$estimate[[2]],
    sr.h1.eff$estimate[[1]] - sr.h1.eff$estimate[[2]],
    sr.h1.rep$estimate[[1]] - sr.h1.rep$estimate[[2]],
    sr.h1.resp$estimate[[1]] - sr.h1.resp$estimate[[2]]
  ),
  "p.value" = c(
    sr.h1.therm$p.value,
    sr.h1.eff$p.value,
    sr.h1.rep$p.value,
    sr.h1.resp$p.value
  )
)

## 1.16 Table A16 ----
sr.h2.therm <- t.test(
  ds$feeling_change[ds$full_treatment == 'Commiserate' & ds$party_sen == "rep"],
  ds$feeling_change[ds$full_treatment == 'Control' & ds$party_sen == "rep"]
)
sr.h2.eff <- t.test(
  ds$effective_change[
    ds$full_treatment == 'Commiserate' & ds$party_sen == "rep"
  ],
  ds$effective_change[ds$full_treatment == 'Control' & ds$party_sen == "rep"]
)
sr.h2.rep <- t.test(
  ds$represent_change[
    ds$full_treatment == 'Commiserate' & ds$party_sen == "rep"
  ],
  ds$represent_change[ds$full_treatment == 'Control' & ds$party_sen == "rep"]
)
sr.h2.resp <- t.test(
  ds$responsible_change[
    ds$full_treatment == 'Commiserate' & ds$party_sen == "rep"
  ],
  ds$responsible_change[ds$full_treatment == 'Control' & ds$party_sen == "rep"]
)

data.frame(
  "DV" = c(
    "Feeling Therm. Rating (0-100) Change",
    "Effectiveness Rating (0-10) Change",
    "Representation Rating (0-10) Change",
    "Responsibility Rating (0-10) Change"
  ),
  "Control" = c(
    sr.h2.therm$estimate[[2]],
    sr.h2.eff$estimate[[2]],
    sr.h2.rep$estimate[[2]],
    sr.h2.resp$estimate[[2]]
  ),
  "Commiserate" = c(
    sr.h2.therm$estimate[[1]],
    sr.h2.eff$estimate[[1]],
    sr.h2.rep$estimate[[1]],
    sr.h2.resp$estimate[[1]]
  ),
  "Diff in Means" = c(
    sr.h2.therm$estimate[[1]] - sr.h2.therm$estimate[[2]],
    sr.h2.eff$estimate[[1]] - sr.h2.eff$estimate[[2]],
    sr.h2.rep$estimate[[1]] - sr.h2.rep$estimate[[2]],
    sr.h2.resp$estimate[[1]] - sr.h2.resp$estimate[[2]]
  ),
  "p.value" = c(
    sr.h2.therm$p.value,
    sr.h2.eff$p.value,
    sr.h2.rep$p.value,
    sr.h2.resp$p.value
  )
)

## 1.17 Table A17 ----
pm.h1.therm <- t.test(
  ds$feeling_change[ds$full_treatment == 'Protect' & ds$party_match == 1],
  ds$feeling_change[ds$full_treatment == 'Credit_Claim' & ds$party_match == 1]
)
pm.h1.eff <- t.test(
  ds$effective_change[ds$full_treatment == 'Protect' & ds$party_match == 1],
  ds$effective_change[ds$full_treatment == 'Credit_Claim' & ds$party_match == 1]
)
pm.h1.rep <- t.test(
  ds$represent_change[ds$full_treatment == 'Protect' & ds$party_match == 1],
  ds$represent_change[ds$full_treatment == 'Credit_Claim' & ds$party_match == 1]
)
pm.h1.resp <- t.test(
  ds$responsible_change[ds$full_treatment == 'Protect' & ds$party_match == 1],
  ds$responsible_change[
    ds$full_treatment == 'Credit_Claim' & ds$party_match == 1
  ]
)

data.frame(
  "DV" = c(
    "Feeling Therm. Rating (0-100) Change",
    "Effectiveness Rating (0-10) Change",
    "Representation Rating (0-10) Change",
    "Responsibility Rating (0-10) Change"
  ),
  "Credit Claim" = c(
    pm.h1.therm$estimate[[2]],
    pm.h1.eff$estimate[[2]],
    pm.h1.rep$estimate[[2]],
    pm.h1.resp$estimate[[2]]
  ),
  "Protect" = c(
    pm.h1.therm$estimate[[1]],
    pm.h1.eff$estimate[[1]],
    pm.h1.rep$estimate[[1]],
    pm.h1.resp$estimate[[1]]
  ),
  "Diff in Means" = c(
    pm.h1.therm$estimate[[1]] - pm.h1.therm$estimate[[2]],
    pm.h1.eff$estimate[[1]] - pm.h1.eff$estimate[[2]],
    pm.h1.rep$estimate[[1]] - pm.h1.rep$estimate[[2]],
    pm.h1.resp$estimate[[1]] - pm.h1.resp$estimate[[2]]
  ),
  "p.value" = c(
    pm.h1.therm$p.value,
    pm.h1.eff$p.value,
    pm.h1.rep$p.value,
    pm.h1.resp$p.value
  )
)

## 1.18 Table A18 ----
pm.h2.therm <- t.test(
  ds$feeling_change[ds$full_treatment == 'Commiserate' & ds$party_match == 1],
  ds$feeling_change[ds$full_treatment == 'Control' & ds$party_match == 1]
)
pm.h2.eff <- t.test(
  ds$effective_change[ds$full_treatment == 'Commiserate' & ds$party_match == 1],
  ds$effective_change[ds$full_treatment == 'Control' & ds$party_match == 1]
)
pm.h2.rep <- t.test(
  ds$represent_change[ds$full_treatment == 'Commiserate' & ds$party_match == 1],
  ds$represent_change[ds$full_treatment == 'Control' & ds$party_match == 1]
)
pm.h2.resp <- t.test(
  ds$responsible_change[
    ds$full_treatment == 'Commiserate' & ds$party_match == 1
  ],
  ds$responsible_change[ds$full_treatment == 'Control' & ds$party_match == 1]
)

data.frame(
  "DV" = c(
    "Feeling Therm. Rating (0-100) Change",
    "Effectiveness Rating (0-10) Change",
    "Representation Rating (0-10) Change",
    "Responsibility Rating (0-10) Change"
  ),
  "Control" = c(
    pm.h2.therm$estimate[[2]],
    pm.h2.eff$estimate[[2]],
    pm.h2.rep$estimate[[2]],
    pm.h2.resp$estimate[[2]]
  ),
  "Commiserate" = c(
    pm.h2.therm$estimate[[1]],
    pm.h2.eff$estimate[[1]],
    pm.h2.rep$estimate[[1]],
    pm.h2.resp$estimate[[1]]
  ),
  "Diff in Means" = c(
    pm.h2.therm$estimate[[1]] - pm.h2.therm$estimate[[2]],
    pm.h2.eff$estimate[[1]] - pm.h2.eff$estimate[[2]],
    pm.h2.rep$estimate[[1]] - pm.h2.rep$estimate[[2]],
    pm.h2.resp$estimate[[1]] - pm.h2.resp$estimate[[2]]
  ),
  "p.value" = c(
    pm.h2.therm$p.value,
    pm.h2.eff$p.value,
    pm.h2.rep$p.value,
    pm.h2.resp$p.value
  )
)

## 1.19 Table A19 ----
npm.h1.therm <- t.test(
  ds$feeling_change[ds$full_treatment == 'Protect' & ds$party_match == -1],
  ds$feeling_change[ds$full_treatment == 'Credit_Claim' & ds$party_match == -1]
)
npm.h1.eff <- t.test(
  ds$effective_change[ds$full_treatment == 'Protect' & ds$party_match == -1],
  ds$effective_change[
    ds$full_treatment == 'Credit_Claim' & ds$party_match == -1
  ]
)
npm.h1.rep <- t.test(
  ds$represent_change[ds$full_treatment == 'Protect' & ds$party_match == -1],
  ds$represent_change[
    ds$full_treatment == 'Credit_Claim' & ds$party_match == -1
  ]
)
npm.h1.resp <- t.test(
  ds$responsible_change[ds$full_treatment == 'Protect' & ds$party_match == -1],
  ds$responsible_change[
    ds$full_treatment == 'Credit_Claim' & ds$party_match == -1
  ]
)

data.frame(
  "DV" = c(
    "Feeling Therm. Rating (0-100) Change",
    "Effectiveness Rating (0-10) Change",
    "Representation Rating (0-10) Change",
    "Responsibility Rating (0-10) Change"
  ),
  "Credit Claim" = c(
    npm.h1.therm$estimate[[2]],
    npm.h1.eff$estimate[[2]],
    npm.h1.rep$estimate[[2]],
    npm.h1.resp$estimate[[2]]
  ),
  "Protect" = c(
    npm.h1.therm$estimate[[1]],
    npm.h1.eff$estimate[[1]],
    npm.h1.rep$estimate[[1]],
    npm.h1.resp$estimate[[1]]
  ),
  "Diff in Means" = c(
    npm.h1.therm$estimate[[1]] - npm.h1.therm$estimate[[2]],
    npm.h1.eff$estimate[[1]] - npm.h1.eff$estimate[[2]],
    npm.h1.rep$estimate[[1]] - npm.h1.rep$estimate[[2]],
    npm.h1.resp$estimate[[1]] - npm.h1.resp$estimate[[2]]
  ),
  "p.value" = c(
    npm.h1.therm$p.value,
    npm.h1.eff$p.value,
    npm.h1.rep$p.value,
    npm.h1.resp$p.value
  )
)

## 1.20 Table A20 ----
npm.h2.therm <- t.test(
  ds$feeling_change[ds$full_treatment == 'Commiserate' & ds$party_match == -1],
  ds$feeling_change[ds$full_treatment == 'Control' & ds$party_match == -1]
)
npm.h2.eff <- t.test(
  ds$effective_change[
    ds$full_treatment == 'Commiserate' & ds$party_match == -1
  ],
  ds$effective_change[ds$full_treatment == 'Control' & ds$party_match == -1]
)
npm.h2.rep <- t.test(
  ds$represent_change[
    ds$full_treatment == 'Commiserate' & ds$party_match == -1
  ],
  ds$represent_change[ds$full_treatment == 'Control' & ds$party_match == -1]
)
npm.h2.resp <- t.test(
  ds$responsible_change[
    ds$full_treatment == 'Commiserate' & ds$party_match == -1
  ],
  ds$responsible_change[ds$full_treatment == 'Control' & ds$party_match == -1]
)

data.frame(
  "DV" = c(
    "Feeling Therm. Rating (0-100) Change",
    "Effectiveness Rating (0-10) Change",
    "Representation Rating (0-10) Change",
    "Responsibility Rating (0-10) Change"
  ),
  "Control" = c(
    npm.h2.therm$estimate[[2]],
    npm.h2.eff$estimate[[2]],
    npm.h2.rep$estimate[[2]],
    npm.h2.resp$estimate[[2]]
  ),
  "Commiserate" = c(
    npm.h2.therm$estimate[[1]],
    npm.h2.eff$estimate[[1]],
    npm.h2.rep$estimate[[1]],
    npm.h2.resp$estimate[[1]]
  ),
  "Diff in Means" = c(
    npm.h2.therm$estimate[[1]] - npm.h2.therm$estimate[[2]],
    npm.h2.eff$estimate[[1]] - npm.h2.eff$estimate[[2]],
    npm.h2.rep$estimate[[1]] - npm.h2.rep$estimate[[2]],
    npm.h2.resp$estimate[[1]] - npm.h2.resp$estimate[[2]]
  ),
  "p.value" = c(
    npm.h2.therm$p.value,
    npm.h2.eff$p.value,
    npm.h2.rep$p.value,
    npm.h2.resp$p.value
  )
)

## 1.21 Table A23 ----
feel_mod_cat <- lm(feeling_change ~ spending_cat, data = ds)
effect_mod_cat <- lm(effective_change ~ spending_cat, data = ds)
rep_mod_cat <- lm(represent_change ~ spending_cat, data = ds)
resp_mod_cat <- lm(responsible_change ~ spending_cat, data = ds)

models_cat <- list()
models_cat[['Thermometer (0-100)']] <- feel_mod_cat
models_cat[['Effectiveness (0-10)']] <- effect_mod_cat
models_cat[['Representation (0-10)']] <- rep_mod_cat
models_cat[['Resposibility (0-10)']] <- resp_mod_cat

coefs_cat <- c(
  "full_treatmentAnnounce" = "Announce",
  "full_treatmentCredit_Claim" = "Credit Claim",
  "full_treatmentCommiserate" = "Commiserate",
  "full_treatmentProtect" = "Protect",
  "spending_catemployment" = "Spending Category: Employment",
  "spending_cathealthcare" = "Spending Category: Healthcare",
  "spending_cattransportation" = "Spending Category: Transportation",
  "spending_cat_threehealthcare" = "Spending Category: Healthcare",
  "spending_cat_threetransportation" = "Spending Category: Transportation",
  "(Intercept)" = "Constant"
)

modelsummary(
  models_cat,
  stars = c('*' = .05, '**' = .01, '***' = .001),
  coef_map = coefs_cat,
  fmt = 2,
  title = '',
  gof_omit = 'R2 Adj.|Log.Lik.|F|AIC|BIC|RMSE',
  notes = "NOTE: Reference treatment = Control"
)

## 1.22 Table A24 ----
feel_mod_treat_cat <- lm(
  feeling_change ~ full_treatment + spending_cat_three,
  data = ds
)

effect_mod_treat_cat <- lm(
  effective_change ~ full_treatment + spending_cat_three,
  data = ds
)

rep_mod_treat_cat <- lm(
  represent_change ~ full_treatment + spending_cat_three,
  data = ds
)

resp_mod_treat_cat <- lm(
  responsible_change ~ full_treatment + spending_cat_three,
  data = ds
)

models_treat_cat <- list()
models_treat_cat[['Thermometer (0-100)']] <- feel_mod_treat_cat
models_treat_cat[['Effectiveness (0-10)']] <- effect_mod_treat_cat
models_treat_cat[['Representation (0-10)']] <- rep_mod_treat_cat
models_treat_cat[['Resposibility (0-10)']] <- resp_mod_treat_cat

modelsummary(
  models_treat_cat,
  stars = c('*' = .05, '**' = .01, '***' = .001),
  coef_map = coefs_cat,
  fmt = 2,
  title = '',
  gof_omit = 'R2 Adj.|Log.Lik.|F|AIC|BIC|RMSE',
  notes = "NOTE: Reference treatment = Control"
)

# 2.0 Figures ----
## 2.1 Figure A1 ----
therm_change_plot_d <-
  ds %>%
  filter(partytwo == 'dem', !is.na(feeling_change)) %>%
  group_by(full_treatment) %>%
  summarise(
    nrow = length(feeling_change),
    mean = mean(feeling_change),
    se = sd(feeling_change) / sqrt(nrow),
    ci = 1.96 * se,
    label = format(round(mean, 2), nsmall = 2)
  ) %>%
  ggplot(., aes(x = full_treatment, y = mean)) +
  geom_pointrange(
    aes(ymin = mean - ci, ymax = mean + ci),
    position = position_dodge(width = .5),
    size = 1,
    linewidth = 1
  ) +
  geom_text(
    aes(x = full_treatment, y = mean - ci, label = label),
    vjust = 1.5,
    size = 3.5
  ) +
  labs(
    y = "Mean Feeling Therm. Change",
    title = "Feeling Thermometer (0-100)",
    x = "Treatment Condition"
  ) +
  scale_x_discrete(
    labels = c(
      "Control" = "Control",
      "Announce" = "Announce",
      "Credit_Claim" = "Credit\nClaim",
      "Commiserate" = "Commiserate",
      "Protect" = "Protect"
    )
  ) +
  scale_y_continuous(limits = c(0, 15))

effect_change_plot_d <-
  ds %>%
  filter(partytwo == 'dem', !is.na(effective_change)) %>%
  group_by(full_treatment) %>%
  summarise(
    nrow = length(effective_change),
    mean = mean(effective_change),
    se = sd(effective_change) / sqrt(nrow),
    ci = 1.96 * se,
    label = format(round(mean, 2), nsmall = 2)
  ) %>%
  ggplot(., aes(x = full_treatment, y = mean)) +
  geom_pointrange(
    aes(ymin = mean - ci, ymax = mean + ci),
    position = position_dodge(width = .5),
    size = 1,
    linewidth = 1
  ) +
  geom_text(
    aes(x = full_treatment, y = mean - ci, label = label),
    vjust = 1.5,
    size = 3.5
  ) +
  labs(
    y = "Mean Effectiveness Change",
    title = "Effectiveness Rating (0-10)",
    x = "Treatment Condition"
  ) +
  scale_x_discrete(
    labels = c(
      "Control" = "Control",
      "Announce" = "Announce",
      "Credit_Claim" = "Credit\nClaim",
      "Commiserate" = "Commiserate",
      "Protect" = "Protect"
    )
  ) +
  scale_y_continuous(limits = c(-.2, 1.5))

represent_change_plot_d <-
  ds %>%
  filter(partytwo == 'dem', !is.na(represent_change)) %>%
  group_by(full_treatment) %>%
  summarise(
    nrow = length(represent_change),
    mean = mean(represent_change),
    se = sd(represent_change) / sqrt(nrow),
    ci = 1.96 * se,
    label = format(round(mean, 2), nsmall = 2)
  ) %>%
  ggplot(., aes(x = full_treatment, y = mean)) +
  geom_pointrange(
    aes(ymin = mean - ci, ymax = mean + ci),
    position = position_dodge(width = .5),
    size = 1,
    linewidth = 1
  ) +
  geom_text(
    aes(x = full_treatment, y = mean - ci, label = label),
    vjust = 1.5,
    size = 3.5
  ) +
  labs(
    y = "Mean Representation Change",
    title = "Representation Rating (0-10)",
    x = "Treatment Condition"
  ) +
  scale_x_discrete(
    labels = c(
      "Control" = "Control",
      "Announce" = "Announce",
      "Credit_Claim" = "Credit\nClaim",
      "Commiserate" = "Commiserate",
      "Protect" = "Protect"
    )
  ) +
  scale_y_continuous(limits = c(-.2, 1.5))

responsible_change_plot_d <-
  ds %>%
  filter(partytwo == 'dem', !is.na(responsible_change)) %>%
  group_by(full_treatment) %>%
  summarise(
    nrow = length(responsible_change),
    mean = mean(responsible_change),
    se = sd(responsible_change) / sqrt(nrow),
    ci = 1.96 * se,
    label = format(round(mean, 2), nsmall = 2)
  ) %>%
  ggplot(., aes(x = full_treatment, y = mean)) +
  geom_pointrange(
    aes(ymin = mean - ci, ymax = mean + ci),
    position = position_dodge(width = .5),
    size = 1,
    linewidth = 1
  ) +
  geom_text(
    aes(x = full_treatment, y = mean - ci, label = label),
    vjust = 1.5,
    size = 3.5
  ) +
  labs(
    y = "Mean Responsibility Change",
    title = "Responsibility Rating (0-10)",
    x = "Treatment Condition"
  ) +
  scale_x_discrete(
    labels = c(
      "Control" = "Control",
      "Announce" = "Announce",
      "Credit_Claim" = "Credit\nClaim",
      "Commiserate" = "Commiserate",
      "Protect" = "Protect"
    )
  ) +
  scale_y_continuous(limits = c(-.2, 1.5))

combined_mean_plots_d <-
  therm_change_plot_d +
  effect_change_plot_d +
  represent_change_plot_d +
  responsible_change_plot_d +
  plot_annotation(
    caption = "NOTE: 95 percent confidence intervals surround point estimates."
  ) &
  theme(plot.caption = element_text(size = 12))

combined_mean_plots_d

## 2.2 Figure A2 ----
figa2.model <-
  summary(
    lm(
      feeling_change ~ full_treatment,
      data = ds %>%
        filter(
          full_treatment %in% c('Announce', 'Commiserate'),
          partytwo == "dem"
        ) %>%
        droplevels()
    )
  )

h3.null.test_d <-
  data.frame(
    estimate = figa2.model$coefficients[2, 1],
    std.error = figa2.model$coefficients[2, 2]
  ) %>%
  mutate(
    ci.lower = estimate - 1.645 * std.error,
    ci.upper = estimate + 1.645 * std.error
  ) %>%
  ggplot(.) +
  geom_point(aes(x = NA, y = estimate), size = 3) +
  geom_errorbar(aes(x = NA, ymin = ci.lower, ymax = ci.upper), width = 0.2) +
  geom_text(
    aes(
      y = estimate,
      x = NA,
      label = glue::glue('[{round(ci.lower,2)}, {round(ci.upper,2)}]')
    ),
    size = 5,
    vjust = -1.25
  ) +
  geom_hline(yintercept = 0, linetype = "dashed", color = "red") +
  geom_hline(yintercept = -3, linetype = "solid", color = "blue") +
  geom_hline(yintercept = 3, linetype = "solid", color = "blue") +
  labs(
    title = "Commiserate Treatment vs. Announce Treatment (Democrats Only)",
    y = "Difference of Means Estimate\n(Feeling Thermometer Rating Change)",
    x = "Commiserate - Announce"
  ) +
  coord_flip()

h3.null.test_d

## 2.3 Figure A3 ----
therm_change_plot_r <-
  ds %>%
  filter(partytwo == 'rep', !is.na(feeling_change)) %>%
  group_by(full_treatment) %>%
  summarise(
    nrow = length(feeling_change),
    mean = mean(feeling_change),
    se = sd(feeling_change) / sqrt(nrow),
    ci = 1.96 * se,
    label = format(round(mean, 2), nsmall = 2)
  ) %>%
  ggplot(., aes(x = full_treatment, y = mean)) +
  geom_pointrange(
    aes(ymin = mean - ci, ymax = mean + ci),
    position = position_dodge(width = .5),
    size = 1,
    linewidth = 1
  ) +
  geom_text(
    aes(x = full_treatment, y = mean - ci, label = label),
    vjust = 1.5,
    size = 3.5
  ) +
  labs(
    y = "Mean Feeling Therm. Change",
    title = "Feeling Thermometer (0-100)",
    x = "Treatment Condition"
  ) +
  scale_x_discrete(
    labels = c(
      "Control" = "Control",
      "Announce" = "Announce",
      "Credit_Claim" = "Credit\nClaim",
      "Commiserate" = "Commiserate",
      "Protect" = "Protect"
    )
  ) +
  scale_y_continuous(limits = c(0, 15))

effect_change_plot_r <-
  ds %>%
  filter(partytwo == 'rep', !is.na(effective_change)) %>%
  group_by(full_treatment) %>%
  summarise(
    nrow = length(effective_change),
    mean = mean(effective_change),
    se = sd(effective_change) / sqrt(nrow),
    ci = 1.96 * se,
    label = format(round(mean, 2), nsmall = 2)
  ) %>%
  ggplot(., aes(x = full_treatment, y = mean)) +
  geom_pointrange(
    aes(ymin = mean - ci, ymax = mean + ci),
    position = position_dodge(width = .5),
    size = 1,
    linewidth = 1
  ) +
  geom_text(
    aes(x = full_treatment, y = mean - ci, label = label),
    vjust = 1.5,
    size = 3.5
  ) +
  labs(
    y = "Mean Effectiveness Change",
    title = "Effectiveness Rating (0-10)",
    x = "Treatment Condition"
  ) +
  scale_x_discrete(
    labels = c(
      "Control" = "Control",
      "Announce" = "Announce",
      "Credit_Claim" = "Credit\nClaim",
      "Commiserate" = "Commiserate",
      "Protect" = "Protect"
    )
  ) +
  scale_y_continuous(limits = c(-.2, 1.5))

represent_change_plot_r <-
  ds %>%
  filter(partytwo == 'rep', !is.na(represent_change)) %>%
  group_by(full_treatment) %>%
  summarise(
    nrow = length(represent_change),
    mean = mean(represent_change),
    se = sd(represent_change) / sqrt(nrow),
    ci = 1.96 * se,
    label = format(round(mean, 2), nsmall = 2)
  ) %>%
  ggplot(., aes(x = full_treatment, y = mean)) +
  geom_pointrange(
    aes(ymin = mean - ci, ymax = mean + ci),
    position = position_dodge(width = .5),
    size = 1,
    linewidth = 1
  ) +
  geom_text(
    aes(x = full_treatment, y = mean - ci, label = label),
    vjust = 1.5,
    size = 3.5
  ) +
  labs(
    y = "Mean Representation Change",
    title = "Representation Rating (0-10)",
    x = "Treatment Condition"
  ) +
  scale_x_discrete(
    labels = c(
      "Control" = "Control",
      "Announce" = "Announce",
      "Credit_Claim" = "Credit\nClaim",
      "Commiserate" = "Commiserate",
      "Protect" = "Protect"
    )
  ) +
  scale_y_continuous(limits = c(-.2, 1.5))

responsible_change_plot_r <-
  ds %>%
  filter(partytwo == 'rep', !is.na(responsible_change)) %>%
  group_by(full_treatment) %>%
  summarise(
    nrow = length(responsible_change),
    mean = mean(responsible_change),
    se = sd(responsible_change) / sqrt(nrow),
    ci = 1.96 * se,
    label = format(round(mean, 2), nsmall = 2)
  ) %>%
  ggplot(., aes(x = full_treatment, y = mean)) +
  geom_pointrange(
    aes(ymin = mean - ci, ymax = mean + ci),
    position = position_dodge(width = .5),
    size = 1,
    linewidth = 1
  ) +
  geom_text(
    aes(x = full_treatment, y = mean - ci, label = label),
    vjust = 1.5,
    size = 3.5
  ) +
  labs(
    y = "Mean Responsibility Change",
    title = "Responsibility Rating (0-10)",
    x = "Treatment Condition"
  ) +
  scale_x_discrete(
    labels = c(
      "Control" = "Control",
      "Announce" = "Announce",
      "Credit_Claim" = "Credit\nClaim",
      "Commiserate" = "Commiserate",
      "Protect" = "Protect"
    )
  ) +
  scale_y_continuous(limits = c(-.2, 1.5))

combined_mean_plots_r <-
  therm_change_plot_r +
  effect_change_plot_r +
  represent_change_plot_r +
  responsible_change_plot_r +
  plot_annotation(
    caption = "NOTE: 95 percent confidence intervals surround point estimates."
  ) &
  theme(plot.caption = element_text(size = 12))

combined_mean_plots_r

## 2.4 Figure A4 ----
figa4.model <-
  summary(
    lm(
      feeling_change ~ full_treatment,
      data = ds %>%
        filter(
          full_treatment %in% c('Announce', 'Commiserate'),
          partytwo == "rep"
        ) %>%
        droplevels()
    )
  )

h3.null.test_r <-
  data.frame(
    estimate = figa4.model$coefficients[2, 1],
    std.error = figa4.model$coefficients[2, 2]
  ) %>%
  mutate(
    ci.lower = estimate - 1.645 * std.error,
    ci.upper = estimate + 1.645 * std.error
  ) %>%
  ggplot(.) +
  geom_point(aes(x = NA, y = estimate), size = 3) +
  geom_errorbar(aes(x = NA, ymin = ci.lower, ymax = ci.upper), width = 0.2) +
  geom_text(
    aes(
      y = estimate,
      x = NA,
      label = glue::glue('[{round(ci.lower,2)}, {round(ci.upper,2)}]')
    ),
    size = 5,
    vjust = -1.25
  ) +
  geom_hline(yintercept = 0, linetype = "dashed", color = "red") +
  geom_hline(yintercept = -3, linetype = "solid", color = "blue") +
  geom_hline(yintercept = 3, linetype = "solid", color = "blue") +
  labs(
    title = "Commiserate Treatment vs. Announce Treatment (Republicans Only)",
    y = "Difference of Means Estimate\n(Feeling Thermometer Rating Change)",
    x = "Commiserate - Announce"
  ) +
  coord_flip()

h3.null.test_r

## 2.5 Figure A5 ----
therm_change_plot_sd <-
  ds %>%
  filter(party_sen == "dem", !is.na(feeling_change)) %>%
  group_by(full_treatment) %>%
  summarise(
    nrow = length(feeling_change),
    mean = mean(feeling_change),
    se = sd(feeling_change) / sqrt(nrow),
    ci = 1.96 * se,
    label = format(round(mean, 2), nsmall = 2)
  ) %>%
  ggplot(., aes(x = full_treatment, y = mean)) +
  geom_pointrange(
    aes(ymin = mean - ci, ymax = mean + ci),
    position = position_dodge(width = .5),
    size = 1,
    linewidth = 1
  ) +
  geom_text(
    aes(x = full_treatment, y = mean - ci, label = label),
    vjust = 1.5,
    size = 3.5
  ) +
  labs(
    y = "Mean Feeling Therm. Change",
    title = "Feeling Thermometer (0-100)",
    x = "Treatment Condition"
  ) +
  scale_x_discrete(
    labels = c(
      "Control" = "Control",
      "Announce" = "Announce",
      "Credit_Claim" = "Credit\nClaim",
      "Commiserate" = "Commiserate",
      "Protect" = "Protect"
    )
  ) +
  scale_y_continuous(limits = c(-5, 15))

effect_change_plot_sd <-
  ds %>%
  filter(party_sen == "dem", !is.na(effective_change)) %>%
  group_by(full_treatment) %>%
  summarise(
    nrow = length(effective_change),
    mean = mean(effective_change),
    se = sd(effective_change) / sqrt(nrow),
    ci = 1.96 * se,
    label = format(round(mean, 2), nsmall = 2)
  ) %>%
  ggplot(., aes(x = full_treatment, y = mean)) +
  geom_pointrange(
    aes(ymin = mean - ci, ymax = mean + ci),
    position = position_dodge(width = .5),
    size = 1,
    linewidth = 1
  ) +
  geom_text(
    aes(x = full_treatment, y = mean - ci, label = label),
    vjust = 1.5,
    size = 3.5
  ) +
  labs(
    y = "Mean Effectiveness Change",
    title = "Effectiveness Rating (0-10)",
    x = "Treatment Condition"
  ) +
  scale_x_discrete(
    labels = c(
      "Control" = "Control",
      "Announce" = "Announce",
      "Credit_Claim" = "Credit\nClaim",
      "Commiserate" = "Commiserate",
      "Protect" = "Protect"
    )
  ) +
  scale_y_continuous(limits = c(-.5, 1.5))

represent_change_plot_sd <-
  ds %>%
  filter(party_sen == "dem", !is.na(represent_change)) %>%
  group_by(full_treatment) %>%
  summarise(
    nrow = length(represent_change),
    mean = mean(represent_change),
    se = sd(represent_change) / sqrt(nrow),
    ci = 1.96 * se,
    label = format(round(mean, 2), nsmall = 2)
  ) %>%
  ggplot(., aes(x = full_treatment, y = mean)) +
  geom_pointrange(
    aes(ymin = mean - ci, ymax = mean + ci),
    position = position_dodge(width = .5),
    size = 1,
    linewidth = 1
  ) +
  geom_text(
    aes(x = full_treatment, y = mean - ci, label = label),
    vjust = 1.5,
    size = 3.5
  ) +
  labs(
    y = "Mean Representation Change",
    title = "Representation Rating (0-10)",
    x = "Treatment Condition"
  ) +
  scale_x_discrete(
    labels = c(
      "Control" = "Control",
      "Announce" = "Announce",
      "Credit_Claim" = "Credit\nClaim",
      "Commiserate" = "Commiserate",
      "Protect" = "Protect"
    )
  ) +
  scale_y_continuous(limits = c(-.5, 1.5))

responsible_change_plot_sd <-
  ds %>%
  filter(party_sen == "dem", !is.na(responsible_change)) %>%
  group_by(full_treatment) %>%
  summarise(
    nrow = length(responsible_change),
    mean = mean(responsible_change),
    se = sd(responsible_change) / sqrt(nrow),
    ci = 1.96 * se,
    label = format(round(mean, 2), nsmall = 2)
  ) %>%
  ggplot(., aes(x = full_treatment, y = mean)) +
  geom_pointrange(
    aes(ymin = mean - ci, ymax = mean + ci),
    position = position_dodge(width = .5),
    size = 1,
    linewidth = 1
  ) +
  geom_text(
    aes(x = full_treatment, y = mean - ci, label = label),
    vjust = 1.5,
    size = 3.5
  ) +
  labs(
    y = "Mean Responsibility Change",
    title = "Responsibility Rating (0-10)",
    x = "Treatment Condition"
  ) +
  scale_x_discrete(
    labels = c(
      "Control" = "Control",
      "Announce" = "Announce",
      "Credit_Claim" = "Credit\nClaim",
      "Commiserate" = "Commiserate",
      "Protect" = "Protect"
    )
  ) +
  scale_y_continuous(limits = c(-.5, 1.5))

combined_change_plot_sd <-
  therm_change_plot_sd +
  effect_change_plot_sd +
  represent_change_plot_sd +
  responsible_change_plot_sd +
  plot_annotation(
    caption = "NOTE: 95 percent confidence intervals surround point estimates."
  ) &
  theme(plot.caption = element_text(size = 12))

combined_change_plot_sd

## 2.6 Figure A6 ----
figa6.model <-
  summary(
    lm(
      feeling_change ~ full_treatment,
      data = ds %>%
        filter(
          full_treatment %in% c('Announce', 'Commiserate'),
          party_sen == "dem"
        ) %>%
        droplevels()
    )
  )

h3.null.test.sd <-
  data.frame(
    estimate = figa6.model$coefficients[2, 1],
    std.error = figa6.model$coefficients[2, 2]
  ) %>%
  mutate(
    ci.lower = estimate - 1.645 * std.error,
    ci.upper = estimate + 1.645 * std.error
  ) %>%
  ggplot(.) +
  geom_point(aes(x = NA, y = estimate), size = 3) +
  geom_errorbar(aes(x = NA, ymin = ci.lower, ymax = ci.upper), width = 0.2) +
  geom_text(
    aes(
      y = estimate,
      x = NA,
      label = glue::glue('[{round(ci.lower,2)}, {round(ci.upper,2)}]')
    ),
    size = 5,
    vjust = -1.25
  ) +
  geom_hline(yintercept = 0, linetype = "dashed", color = "red") +
  geom_hline(yintercept = -3, linetype = "solid", color = "blue") +
  geom_hline(yintercept = 3, linetype = "solid", color = "blue") +
  labs(
    title = "Commiserate Treatment vs. Announce Treatment (Democratic Senators)",
    y = "Difference of Means Estimate\n(Feeling Thermometer Rating Change)",
    x = "Commiserate - Announce"
  ) +
  coord_flip()

h3.null.test.sd

## 2.7 Figure A7 ----
therm_change_plot_sr <-
  ds %>%
  filter(party_sen == "rep", !is.na(feeling_change)) %>%
  group_by(full_treatment) %>%
  summarise(
    nrow = length(feeling_change),
    mean = mean(feeling_change),
    se = sd(feeling_change) / sqrt(nrow),
    ci = 1.96 * se,
    label = format(round(mean, 2), nsmall = 2)
  ) %>%
  ggplot(., aes(x = full_treatment, y = mean)) +
  geom_pointrange(
    aes(ymin = mean - ci, ymax = mean + ci),
    position = position_dodge(width = .5),
    size = 1,
    linewidth = 1
  ) +
  geom_text(
    aes(x = full_treatment, y = mean - ci, label = label),
    vjust = 1.5,
    size = 3.5
  ) +
  labs(
    y = "Mean Feeling Therm. Change",
    title = "Feeling Thermometer (0-100)",
    x = "Treatment Condition"
  ) +
  scale_x_discrete(
    labels = c(
      "Control" = "Control",
      "Announce" = "Announce",
      "Credit_Claim" = "Credit\nClaim",
      "Commiserate" = "Commiserate",
      "Protect" = "Protect"
    )
  ) +
  scale_y_continuous(limits = c(-5, 15))

effect_change_plot_sr <-
  ds %>%
  filter(party_sen == "rep", !is.na(effective_change)) %>%
  group_by(full_treatment) %>%
  summarise(
    nrow = length(effective_change),
    mean = mean(effective_change),
    se = sd(effective_change) / sqrt(nrow),
    ci = 1.96 * se,
    label = format(round(mean, 2), nsmall = 2)
  ) %>%
  ggplot(., aes(x = full_treatment, y = mean)) +
  geom_pointrange(
    aes(ymin = mean - ci, ymax = mean + ci),
    position = position_dodge(width = .5),
    size = 1,
    linewidth = 1
  ) +
  geom_text(
    aes(x = full_treatment, y = mean - ci, label = label),
    vjust = 1.5,
    size = 3.5
  ) +
  labs(
    y = "Mean Effectiveness Change",
    title = "Effectiveness Rating (0-10)",
    x = "Treatment Condition"
  ) +
  scale_x_discrete(
    labels = c(
      "Control" = "Control",
      "Announce" = "Announce",
      "Credit_Claim" = "Credit\nClaim",
      "Commiserate" = "Commiserate",
      "Protect" = "Protect"
    )
  ) +
  scale_y_continuous(limits = c(-.5, 1.5))

represent_change_plot_sr <-
  ds %>%
  filter(party_sen == "rep", !is.na(represent_change)) %>%
  group_by(full_treatment) %>%
  summarise(
    nrow = length(represent_change),
    mean = mean(represent_change),
    se = sd(represent_change) / sqrt(nrow),
    ci = 1.96 * se,
    label = format(round(mean, 2), nsmall = 2)
  ) %>%
  ggplot(., aes(x = full_treatment, y = mean)) +
  geom_pointrange(
    aes(ymin = mean - ci, ymax = mean + ci),
    position = position_dodge(width = .5),
    size = 1,
    linewidth = 1
  ) +
  geom_text(
    aes(x = full_treatment, y = mean - ci, label = label),
    vjust = 1.5,
    size = 3.5
  ) +
  labs(
    y = "Mean Representation Change",
    title = "Representation Rating (0-10)",
    x = "Treatment Condition"
  ) +
  scale_x_discrete(
    labels = c(
      "Control" = "Control",
      "Announce" = "Announce",
      "Credit_Claim" = "Credit\nClaim",
      "Commiserate" = "Commiserate",
      "Protect" = "Protect"
    )
  ) +
  scale_y_continuous(limits = c(-.5, 1.5))

responsible_change_plot_sr <-
  ds %>%
  filter(party_sen == "rep", !is.na(responsible_change)) %>%
  group_by(full_treatment) %>%
  summarise(
    nrow = length(responsible_change),
    mean = mean(responsible_change),
    se = sd(responsible_change) / sqrt(nrow),
    ci = 1.96 * se,
    label = format(round(mean, 2), nsmall = 2)
  ) %>%
  ggplot(., aes(x = full_treatment, y = mean)) +
  geom_pointrange(
    aes(ymin = mean - ci, ymax = mean + ci),
    position = position_dodge(width = .5),
    size = 1,
    linewidth = 1
  ) +
  geom_text(
    aes(x = full_treatment, y = mean - ci, label = label),
    vjust = 1.5,
    size = 3.5
  ) +
  labs(
    y = "Mean Responsibility Change",
    title = "Responsibility Rating (0-10)",
    x = "Treatment Condition"
  ) +
  scale_x_discrete(
    labels = c(
      "Control" = "Control",
      "Announce" = "Announce",
      "Credit_Claim" = "Credit\nClaim",
      "Commiserate" = "Commiserate",
      "Protect" = "Protect"
    )
  ) +
  scale_y_continuous(limits = c(-.5, 1.5))

combined_change_plot_sr <-
  therm_change_plot_sr +
  effect_change_plot_sr +
  represent_change_plot_sr +
  responsible_change_plot_sr +
  plot_annotation(
    caption = "NOTE: 95 percent confidence intervals surround point estimates."
  ) &
  theme(plot.caption = element_text(size = 12))

combined_change_plot_sr

## 2.8 Figure A8 ----
figa8.model <-
  summary(
    lm(
      feeling_change ~ full_treatment,
      data = ds %>%
        filter(
          full_treatment %in% c('Announce', 'Commiserate'),
          party_sen == "rep"
        ) %>%
        droplevels()
    )
  )

h3.null.test.sr <-
  data.frame(
    estimate = figa8.model$coefficients[2, 1],
    std.error = figa8.model$coefficients[2, 2]
  ) %>%
  mutate(
    ci.lower = estimate - 1.645 * std.error,
    ci.upper = estimate + 1.645 * std.error
  ) %>%
  ggplot(.) +
  geom_point(aes(x = NA, y = estimate), size = 3) +
  geom_errorbar(aes(x = NA, ymin = ci.lower, ymax = ci.upper), width = 0.2) +
  geom_text(
    aes(
      y = estimate,
      x = NA,
      label = glue::glue('[{round(ci.lower,2)}, {round(ci.upper,2)}]')
    ),
    size = 5,
    vjust = -1.25
  ) +
  geom_hline(yintercept = 0, linetype = "dashed", color = "red") +
  geom_hline(yintercept = -3, linetype = "solid", color = "blue") +
  geom_hline(yintercept = 3, linetype = "solid", color = "blue") +
  labs(
    title = "Commiserate Treatment vs. Announce Treatment (Republican Senators)",
    y = "Difference of Means Estimate\n(Feeling Thermometer Rating Change)",
    x = "Commiserate - Announce"
  ) +
  coord_flip()

h3.null.test.sr

## 2.9 Figure A9 ----
therm_change_plot_pm <-
  ds %>%
  filter(party_match == 1, !is.na(feeling_change)) %>%
  group_by(full_treatment) %>%
  summarise(
    nrow = length(feeling_change),
    mean = mean(feeling_change),
    se = sd(feeling_change) / sqrt(nrow),
    ci = 1.96 * se,
    label = format(round(mean, 2), nsmall = 2)
  ) %>%
  ggplot(., aes(x = full_treatment, y = mean)) +
  geom_pointrange(
    aes(ymin = mean - ci, ymax = mean + ci),
    position = position_dodge(width = .5),
    size = 1,
    linewidth = 1
  ) +
  geom_text(
    aes(x = full_treatment, y = mean - ci, label = label),
    vjust = 1.5,
    size = 3.5
  ) +
  labs(
    y = "Mean Feeling Therm. Change",
    title = "Feeling Thermometer (0-100)",
    x = "Treatment Condition"
  ) +
  scale_x_discrete(
    labels = c(
      "Control" = "Control",
      "Announce" = "Announce",
      "Credit_Claim" = "Credit\nClaim",
      "Commiserate" = "Commiserate",
      "Protect" = "Protect"
    )
  ) +
  scale_y_continuous(limits = c(-5, 20))

effect_change_plot_pm <-
  ds %>%
  filter(party_match == 1, !is.na(effective_change)) %>%
  group_by(full_treatment) %>%
  summarise(
    nrow = length(effective_change),
    mean = mean(effective_change),
    se = sd(effective_change) / sqrt(nrow),
    ci = 1.96 * se,
    label = format(round(mean, 2), nsmall = 2)
  ) %>%
  ggplot(., aes(x = full_treatment, y = mean)) +
  geom_pointrange(
    aes(ymin = mean - ci, ymax = mean + ci),
    position = position_dodge(width = .5),
    size = 1,
    linewidth = 1
  ) +
  geom_text(
    aes(x = full_treatment, y = mean - ci, label = label),
    vjust = 1.5,
    size = 3.5
  ) +
  labs(
    y = "Mean Effectiveness Change",
    title = "Effectiveness Rating (0-10)",
    x = "Treatment Condition"
  ) +
  scale_x_discrete(
    labels = c(
      "Control" = "Control",
      "Announce" = "Announce",
      "Credit_Claim" = "Credit\nClaim",
      "Commiserate" = "Commiserate",
      "Protect" = "Protect"
    )
  ) +
  scale_y_continuous(limits = c(-.5, 2))

represent_change_plot_pm <-
  ds %>%
  filter(party_match == 1, !is.na(represent_change)) %>%
  group_by(full_treatment) %>%
  summarise(
    nrow = length(represent_change),
    mean = mean(represent_change),
    se = sd(represent_change) / sqrt(nrow),
    ci = 1.96 * se,
    label = format(round(mean, 2), nsmall = 2)
  ) %>%
  ggplot(., aes(x = full_treatment, y = mean)) +
  geom_pointrange(
    aes(ymin = mean - ci, ymax = mean + ci),
    position = position_dodge(width = .5),
    size = 1,
    linewidth = 1
  ) +
  geom_text(
    aes(x = full_treatment, y = mean - ci, label = label),
    vjust = 1.5,
    size = 3.5
  ) +
  labs(
    y = "Mean Representation Change",
    title = "Representation Rating (0-10)",
    x = "Treatment Condition"
  ) +
  scale_x_discrete(
    labels = c(
      "Control" = "Control",
      "Announce" = "Announce",
      "Credit_Claim" = "Credit\nClaim",
      "Commiserate" = "Commiserate",
      "Protect" = "Protect"
    )
  ) +
  scale_y_continuous(limits = c(-.5, 2))

responsible_change_plot_pm <-
  ds %>%
  filter(party_match == 1, !is.na(responsible_change)) %>%
  group_by(full_treatment) %>%
  summarise(
    nrow = length(responsible_change),
    mean = mean(responsible_change),
    se = sd(responsible_change) / sqrt(nrow),
    ci = 1.96 * se,
    label = format(round(mean, 2), nsmall = 2)
  ) %>%
  ggplot(., aes(x = full_treatment, y = mean)) +
  geom_pointrange(
    aes(ymin = mean - ci, ymax = mean + ci),
    position = position_dodge(width = .5),
    size = 1,
    linewidth = 1
  ) +
  geom_text(
    aes(x = full_treatment, y = mean - ci, label = label),
    vjust = 1.5,
    size = 3.5
  ) +
  labs(
    y = "Mean Responsibility Change",
    title = "Responsibility Rating (0-10)",
    x = "Treatment Condition"
  ) +
  scale_x_discrete(
    labels = c(
      "Control" = "Control",
      "Announce" = "Announce",
      "Credit_Claim" = "Credit\nClaim",
      "Commiserate" = "Commiserate",
      "Protect" = "Protect"
    )
  ) +
  scale_y_continuous(limits = c(-.5, 2))

combined_change_plot_pm <-
  therm_change_plot_pm +
  effect_change_plot_pm +
  represent_change_plot_pm +
  responsible_change_plot_pm +
  plot_annotation(
    caption = "NOTE: 95 percent confidence intervals surround point estimates."
  ) &
  theme(plot.caption = element_text(size = 12))

combined_change_plot_pm

## 2.10 Figure A10 ----
figa10.model <-
  summary(
    lm(
      feeling_change ~ full_treatment,
      data = ds %>%
        filter(
          full_treatment %in% c('Announce', 'Commiserate'),
          party_match == 1
        ) %>%
        droplevels()
    )
  )

h3.null.test.pm <-
  data.frame(
    estimate = figa10.model$coefficients[2, 1],
    std.error = figa10.model$coefficients[2, 2]
  ) %>%
  mutate(
    ci.lower = estimate - 1.645 * std.error,
    ci.upper = estimate + 1.645 * std.error
  ) %>%
  ggplot(.) +
  geom_point(aes(x = NA, y = estimate), size = 3) +
  geom_errorbar(aes(x = NA, ymin = ci.lower, ymax = ci.upper), width = 0.2) +
  geom_text(
    aes(
      y = estimate,
      x = NA,
      label = glue::glue('[{round(ci.lower,2)}, {round(ci.upper,2)}]')
    ),
    size = 5,
    vjust = -1.25
  ) +
  geom_hline(yintercept = 0, linetype = "dashed", color = "red") +
  geom_hline(yintercept = -3, linetype = "solid", color = "blue") +
  geom_hline(yintercept = 3, linetype = "solid", color = "blue") +
  labs(
    title = "Commiserate Treatment vs. Announce Treatment (Copartisans)",
    y = "Difference of Means Estimate\n(Feeling Thermometer Rating Change)",
    x = "Commiserate - Announce"
  ) +
  coord_flip()

h3.null.test.pm

## 2.11 Figure A11 ----
therm_change_plot_npm <-
  ds %>%
  filter(party_match == -1, !is.na(feeling_change)) %>%
  group_by(full_treatment) %>%
  summarise(
    nrow = length(feeling_change),
    mean = mean(feeling_change),
    se = sd(feeling_change) / sqrt(nrow),
    ci = 1.96 * se,
    label = format(round(mean, 2), nsmall = 2)
  ) %>%
  ggplot(., aes(x = full_treatment, y = mean)) +
  geom_pointrange(
    aes(ymin = mean - ci, ymax = mean + ci),
    position = position_dodge(width = .5),
    size = 1,
    linewidth = 1
  ) +
  geom_text(
    aes(x = full_treatment, y = mean - ci, label = label),
    vjust = 1.5,
    size = 3.5
  ) +
  labs(
    y = "Mean Feeling Therm. Change",
    title = "Feeling Thermometer (0-100)",
    x = "Treatment Condition"
  ) +
  scale_x_discrete(
    labels = c(
      "Control" = "Control",
      "Announce" = "Announce",
      "Credit_Claim" = "Credit\nClaim",
      "Commiserate" = "Commiserate",
      "Protect" = "Protect"
    )
  ) +
  scale_y_continuous(limits = c(-5, 20))

effect_change_plot_npm <-
  ds %>%
  filter(party_match == -1, !is.na(effective_change)) %>%
  group_by(full_treatment) %>%
  summarise(
    nrow = length(effective_change),
    mean = mean(effective_change),
    se = sd(effective_change) / sqrt(nrow),
    ci = 1.96 * se,
    label = format(round(mean, 2), nsmall = 2)
  ) %>%
  ggplot(., aes(x = full_treatment, y = mean)) +
  geom_pointrange(
    aes(ymin = mean - ci, ymax = mean + ci),
    position = position_dodge(width = .5),
    size = 1,
    linewidth = 1
  ) +
  geom_text(
    aes(x = full_treatment, y = mean - ci, label = label),
    vjust = 1.5,
    size = 3.5
  ) +
  labs(
    y = "Mean Effectiveness Change",
    title = "Effectiveness Rating (0-10)",
    x = "Treatment Condition"
  ) +
  scale_x_discrete(
    labels = c(
      "Control" = "Control",
      "Announce" = "Announce",
      "Credit_Claim" = "Credit\nClaim",
      "Commiserate" = "Commiserate",
      "Protect" = "Protect"
    )
  ) +
  scale_y_continuous(limits = c(-.5, 2))

represent_change_plot_npm <-
  ds %>%
  filter(party_match == -1, !is.na(represent_change)) %>%
  group_by(full_treatment) %>%
  summarise(
    nrow = length(represent_change),
    mean = mean(represent_change),
    se = sd(represent_change) / sqrt(nrow),
    ci = 1.96 * se,
    label = format(round(mean, 2), nsmall = 2)
  ) %>%
  ggplot(., aes(x = full_treatment, y = mean)) +
  geom_pointrange(
    aes(ymin = mean - ci, ymax = mean + ci),
    position = position_dodge(width = .5),
    size = 1,
    linewidth = 1
  ) +
  geom_text(
    aes(x = full_treatment, y = mean - ci, label = label),
    vjust = 1.5,
    size = 3.5
  ) +
  labs(
    y = "Mean Representation Change",
    title = "Representation Rating (0-10)",
    x = "Treatment Condition"
  ) +
  scale_x_discrete(
    labels = c(
      "Control" = "Control",
      "Announce" = "Announce",
      "Credit_Claim" = "Credit\nClaim",
      "Commiserate" = "Commiserate",
      "Protect" = "Protect"
    )
  ) +
  scale_y_continuous(limits = c(-.5, 2))

responsible_change_plot_npm <-
  ds %>%
  filter(party_match == -1, !is.na(responsible_change)) %>%
  group_by(full_treatment) %>%
  summarise(
    nrow = length(responsible_change),
    mean = mean(responsible_change),
    se = sd(responsible_change) / sqrt(nrow),
    ci = 1.96 * se,
    label = format(round(mean, 2), nsmall = 2)
  ) %>%
  ggplot(., aes(x = full_treatment, y = mean)) +
  geom_pointrange(
    aes(ymin = mean - ci, ymax = mean + ci),
    position = position_dodge(width = .5),
    size = 1,
    linewidth = 1
  ) +
  geom_text(
    aes(x = full_treatment, y = mean - ci, label = label),
    vjust = 1.5,
    size = 3.5
  ) +
  labs(
    y = "Mean Responsibility Change",
    title = "Responsibility Rating (0-10)",
    x = "Treatment Condition"
  ) +
  scale_x_discrete(
    labels = c(
      "Control" = "Control",
      "Announce" = "Announce",
      "Credit_Claim" = "Credit\nClaim",
      "Commiserate" = "Commiserate",
      "Protect" = "Protect"
    )
  ) +
  scale_y_continuous(limits = c(-.5, 2))

combined_change_plot_npm <-
  therm_change_plot_npm +
  effect_change_plot_npm +
  represent_change_plot_npm +
  responsible_change_plot_npm +
  plot_annotation(
    caption = "NOTE: 95 percent confidence intervals surround point estimates."
  ) &
  theme(plot.caption = element_text(size = 12))

combined_change_plot_npm

## 2.12 Figure A12 ----
figa12.model <-
  summary(
    lm(
      feeling_change ~ full_treatment,
      data = ds %>%
        filter(
          full_treatment %in% c('Announce', 'Commiserate'),
          party_match == -1
        ) %>%
        droplevels()
    )
  )

h3.null.test.npm <-
  data.frame(
    estimate = figa12.model$coefficients[2, 1],
    std.error = figa12.model$coefficients[2, 2]
  ) %>%
  mutate(
    ci.lower = estimate - 1.645 * std.error,
    ci.upper = estimate + 1.645 * std.error
  ) %>%
  ggplot(.) +
  geom_point(aes(x = NA, y = estimate), size = 3) +
  geom_errorbar(aes(x = NA, ymin = ci.lower, ymax = ci.upper), width = 0.2) +
  geom_text(
    aes(
      y = estimate,
      x = NA,
      label = glue::glue('[{round(ci.lower,2)}, {round(ci.upper,2)}]')
    ),
    size = 5,
    vjust = -1.25
  ) +
  geom_hline(yintercept = 0, linetype = "dashed", color = "red") +
  geom_hline(yintercept = -3, linetype = "solid", color = "blue") +
  geom_hline(yintercept = 3, linetype = "solid", color = "blue") +
  labs(
    title = "Commiserate Treatment vs. Announce Treatment (Opposing Partisans)",
    y = "Difference of Means Estimate\n(Feeling Thermometer Rating Change)",
    x = "Commiserate - Announce"
  ) +
  coord_flip()

h3.null.test.npm

## 2.13 Figure A13 ----
therm_change_plot_health <-
  ds %>%
  filter(
    spending_cat %in% c('control', 'healthcare'),
    !is.na(feeling_change)
  ) %>%
  group_by(full_treatment) %>%
  summarise(
    nrow = length(feeling_change),
    mean = mean(feeling_change),
    se = sd(feeling_change) / sqrt(nrow),
    ci = 1.96 * se,
    label = format(round(mean, 2), nsmall = 2)
  ) %>%
  ggplot(., aes(x = full_treatment, y = mean)) +
  geom_pointrange(
    aes(ymin = mean - ci, ymax = mean + ci),
    position = position_dodge(width = .5),
    size = 1,
    linewidth = 1
  ) +
  geom_text(
    aes(x = full_treatment, y = mean - ci, label = label),
    vjust = 1.5,
    size = 3.5
  ) +
  labs(
    y = "Mean Feeling Therm. Change",
    title = "Feeling Thermometer (0-100)",
    x = "Treatment Condition"
  ) +
  scale_x_discrete(
    labels = c(
      "Control" = "Control",
      "Announce" = "Announce",
      "Credit_Claim" = "Credit\nClaim",
      "Commiserate" = "Commiserate",
      "Protect" = "Protect"
    )
  ) +
  scale_y_continuous(limits = c(0, 18))

effect_change_plot_health <-
  ds %>%
  filter(
    spending_cat %in% c('control', 'healthcare'),
    !is.na(effective_change)
  ) %>%
  group_by(full_treatment) %>%
  summarise(
    nrow = length(effective_change),
    mean = mean(effective_change),
    se = sd(effective_change) / sqrt(nrow),
    ci = 1.96 * se,
    label = format(round(mean, 2), nsmall = 2)
  ) %>%
  ggplot(., aes(x = full_treatment, y = mean)) +
  geom_pointrange(
    aes(ymin = mean - ci, ymax = mean + ci),
    position = position_dodge(width = .5),
    size = 1,
    linewidth = 1
  ) +
  geom_text(
    aes(x = full_treatment, y = mean - ci, label = label),
    vjust = 1.5,
    size = 3.5
  ) +
  labs(
    y = "Mean Effectiveness Change",
    title = "Effectiveness Rating (0-10)",
    x = "Treatment Condition"
  ) +
  scale_x_discrete(
    labels = c(
      "Control" = "Control",
      "Announce" = "Announce",
      "Credit_Claim" = "Credit\nClaim",
      "Commiserate" = "Commiserate",
      "Protect" = "Protect"
    )
  ) +
  scale_y_continuous(limits = c(-.2, 1.8))

represent_change_plot_health <-
  ds %>%
  filter(
    spending_cat %in% c('control', 'healthcare'),
    !is.na(represent_change)
  ) %>%
  group_by(full_treatment) %>%
  summarise(
    nrow = length(represent_change),
    mean = mean(represent_change),
    se = sd(represent_change) / sqrt(nrow),
    ci = 1.96 * se,
    label = format(round(mean, 2), nsmall = 2)
  ) %>%
  ggplot(., aes(x = full_treatment, y = mean)) +
  geom_pointrange(
    aes(ymin = mean - ci, ymax = mean + ci),
    position = position_dodge(width = .5),
    size = 1,
    linewidth = 1
  ) +
  geom_text(
    aes(x = full_treatment, y = mean - ci, label = label),
    vjust = 1.5,
    size = 3.5
  ) +
  labs(
    y = "Mean Representation Change",
    title = "Representation Rating (0-10)",
    x = "Treatment Condition"
  ) +
  scale_x_discrete(
    labels = c(
      "Control" = "Control",
      "Announce" = "Announce",
      "Credit_Claim" = "Credit\nClaim",
      "Commiserate" = "Commiserate",
      "Protect" = "Protect"
    )
  ) +
  scale_y_continuous(limits = c(-.2, 1.8))

responsible_change_plot_health <-
  ds %>%
  filter(
    spending_cat %in% c('control', 'healthcare'),
    !is.na(responsible_change)
  ) %>%
  group_by(full_treatment) %>%
  summarise(
    nrow = length(responsible_change),
    mean = mean(responsible_change),
    se = sd(responsible_change) / sqrt(nrow),
    ci = 1.96 * se,
    label = format(round(mean, 2), nsmall = 2)
  ) %>%
  ggplot(., aes(x = full_treatment, y = mean)) +
  geom_pointrange(
    aes(ymin = mean - ci, ymax = mean + ci),
    position = position_dodge(width = .5),
    size = 1,
    linewidth = 1
  ) +
  geom_text(
    aes(x = full_treatment, y = mean - ci, label = label),
    vjust = 1.5,
    size = 3.5
  ) +
  labs(
    y = "Mean Responsibility Change",
    title = "Responsibility Rating (0-10)",
    x = "Treatment Condition"
  ) +
  scale_x_discrete(
    labels = c(
      "Control" = "Control",
      "Announce" = "Announce",
      "Credit_Claim" = "Credit\nClaim",
      "Commiserate" = "Commiserate",
      "Protect" = "Protect"
    )
  ) +
  scale_y_continuous(limits = c(-.2, 1.8))

combined_mean_plots_health <-
  therm_change_plot_health +
  effect_change_plot_health +
  represent_change_plot_health +
  responsible_change_plot_health +
  plot_annotation(
    caption = "NOTE: 95 percent confidence intervals surround point estimates."
  ) &
  theme(plot.caption = element_text(size = 12))

combined_mean_plots_health

## 2.14 Figure A14 ----
therm_change_plot_trans <-
  ds %>%
  filter(
    spending_cat %in% c('control', 'transportation'),
    !is.na(feeling_change)
  ) %>%
  group_by(full_treatment) %>%
  summarise(
    nrow = length(feeling_change),
    mean = mean(feeling_change),
    se = sd(feeling_change) / sqrt(nrow),
    ci = 1.96 * se,
    label = format(round(mean, 2), nsmall = 2)
  ) %>%
  ggplot(., aes(x = full_treatment, y = mean)) +
  geom_pointrange(
    aes(ymin = mean - ci, ymax = mean + ci),
    position = position_dodge(width = .5),
    size = 1,
    linewidth = 1
  ) +
  geom_text(
    aes(x = full_treatment, y = mean - ci, label = label),
    vjust = 1.5,
    size = 3.5
  ) +
  labs(
    y = "Mean Feeling Therm. Change",
    title = "Feeling Thermometer (0-100)",
    x = "Treatment Condition"
  ) +
  scale_x_discrete(
    labels = c(
      "Control" = "Control",
      "Announce" = "Announce",
      "Credit_Claim" = "Credit\nClaim",
      "Commiserate" = "Commiserate",
      "Protect" = "Protect"
    )
  ) +
  scale_y_continuous(limits = c(0, 15))

effect_change_plot_trans <-
  ds %>%
  filter(
    spending_cat %in% c('control', 'transportation'),
    !is.na(effective_change)
  ) %>%
  group_by(full_treatment) %>%
  summarise(
    nrow = length(effective_change),
    mean = mean(effective_change),
    se = sd(effective_change) / sqrt(nrow),
    ci = 1.96 * se,
    label = format(round(mean, 2), nsmall = 2)
  ) %>%
  ggplot(., aes(x = full_treatment, y = mean)) +
  geom_pointrange(
    aes(ymin = mean - ci, ymax = mean + ci),
    position = position_dodge(width = .5),
    size = 1,
    linewidth = 1
  ) +
  geom_text(
    aes(x = full_treatment, y = mean - ci, label = label),
    vjust = 1.5,
    size = 3.5
  ) +
  labs(
    y = "Mean Effectiveness Change",
    title = "Effectiveness Rating (0-10)",
    x = "Treatment Condition"
  ) +
  scale_x_discrete(
    labels = c(
      "Control" = "Control",
      "Announce" = "Announce",
      "Credit_Claim" = "Credit\nClaim",
      "Commiserate" = "Commiserate",
      "Protect" = "Protect"
    )
  ) +
  scale_y_continuous(limits = c(-.2, 1.5))

represent_change_plot_trans <-
  ds %>%
  filter(
    spending_cat %in% c('control', 'transportation'),
    !is.na(represent_change)
  ) %>%
  group_by(full_treatment) %>%
  summarise(
    nrow = length(represent_change),
    mean = mean(represent_change),
    se = sd(represent_change) / sqrt(nrow),
    ci = 1.96 * se,
    label = format(round(mean, 2), nsmall = 2)
  ) %>%
  ggplot(., aes(x = full_treatment, y = mean)) +
  geom_pointrange(
    aes(ymin = mean - ci, ymax = mean + ci),
    position = position_dodge(width = .5),
    size = 1,
    linewidth = 1
  ) +
  geom_text(
    aes(x = full_treatment, y = mean - ci, label = label),
    vjust = 1.5,
    size = 3.5
  ) +
  labs(
    y = "Mean Representation Change",
    title = "Representation Rating (0-10)",
    x = "Treatment Condition"
  ) +
  scale_x_discrete(
    labels = c(
      "Control" = "Control",
      "Announce" = "Announce",
      "Credit_Claim" = "Credit\nClaim",
      "Commiserate" = "Commiserate",
      "Protect" = "Protect"
    )
  ) +
  scale_y_continuous(limits = c(-.2, 1.5))

responsible_change_plot_trans <-
  ds %>%
  filter(
    spending_cat %in% c('control', 'transportation'),
    !is.na(responsible_change)
  ) %>%
  group_by(full_treatment) %>%
  summarise(
    nrow = length(responsible_change),
    mean = mean(responsible_change),
    se = sd(responsible_change) / sqrt(nrow),
    ci = 1.96 * se,
    label = format(round(mean, 2), nsmall = 2)
  ) %>%
  ggplot(., aes(x = full_treatment, y = mean)) +
  geom_pointrange(
    aes(ymin = mean - ci, ymax = mean + ci),
    position = position_dodge(width = .5),
    size = 1,
    linewidth = 1
  ) +
  geom_text(
    aes(x = full_treatment, y = mean - ci, label = label),
    vjust = 1.5,
    size = 3.5
  ) +
  labs(
    y = "Mean Responsibility Change",
    title = "Responsibility Rating (0-10)",
    x = "Treatment Condition"
  ) +
  scale_x_discrete(
    labels = c(
      "Control" = "Control",
      "Announce" = "Announce",
      "Credit_Claim" = "Credit\nClaim",
      "Commiserate" = "Commiserate",
      "Protect" = "Protect"
    )
  ) +
  scale_y_continuous(limits = c(-.2, 1.5))

combined_mean_plots_trans <-
  therm_change_plot_trans +
  effect_change_plot_trans +
  represent_change_plot_trans +
  responsible_change_plot_trans +
  plot_annotation(
    caption = "NOTE: 95 percent confidence intervals surround point estimates."
  ) &
  theme(plot.caption = element_text(size = 12))

combined_mean_plots_trans

## 2.15 Figure A15 ----
therm_change_plot_employ <-
  ds %>%
  filter(
    spending_cat %in% c('control', 'employment'),
    !is.na(feeling_change)
  ) %>%
  group_by(full_treatment) %>%
  summarise(
    nrow = length(feeling_change),
    mean = mean(feeling_change),
    se = sd(feeling_change) / sqrt(nrow),
    ci = 1.96 * se,
    label = format(round(mean, 2), nsmall = 2)
  ) %>%
  ggplot(., aes(x = full_treatment, y = mean)) +
  geom_pointrange(
    aes(ymin = mean - ci, ymax = mean + ci),
    position = position_dodge(width = .5),
    size = 1,
    linewidth = 1
  ) +
  geom_text(
    aes(x = full_treatment, y = mean - ci, label = label),
    vjust = 1.5,
    size = 3.5
  ) +
  labs(
    y = "Mean Feeling Therm. Change",
    title = "Feeling Thermometer (0-100)",
    x = "Treatment Condition"
  ) +
  scale_x_discrete(
    labels = c(
      "Control" = "Control",
      "Announce" = "Announce",
      "Credit_Claim" = "Credit\nClaim",
      "Commiserate" = "Commiserate",
      "Protect" = "Protect"
    )
  ) +
  scale_y_continuous(limits = c(0, 15))

effect_change_plot_employ <-
  ds %>%
  filter(
    spending_cat %in% c('control', 'employment'),
    !is.na(effective_change)
  ) %>%
  group_by(full_treatment) %>%
  summarise(
    nrow = length(effective_change),
    mean = mean(effective_change),
    se = sd(effective_change) / sqrt(nrow),
    ci = 1.96 * se,
    label = format(round(mean, 2), nsmall = 2)
  ) %>%
  ggplot(., aes(x = full_treatment, y = mean)) +
  geom_pointrange(
    aes(ymin = mean - ci, ymax = mean + ci),
    position = position_dodge(width = .5),
    size = 1,
    linewidth = 1
  ) +
  geom_text(
    aes(x = full_treatment, y = mean - ci, label = label),
    vjust = 1.5,
    size = 3.5
  ) +
  labs(
    y = "Mean Effectiveness Change",
    title = "Effectiveness Rating (0-10)",
    x = "Treatment Condition"
  ) +
  scale_x_discrete(
    labels = c(
      "Control" = "Control",
      "Announce" = "Announce",
      "Credit_Claim" = "Credit\nClaim",
      "Commiserate" = "Commiserate",
      "Protect" = "Protect"
    )
  ) +
  scale_y_continuous(limits = c(-.2, 1.5))

represent_change_plot_employ <-
  ds %>%
  filter(
    spending_cat %in% c('control', 'employment'),
    !is.na(represent_change)
  ) %>%
  group_by(full_treatment) %>%
  summarise(
    nrow = length(represent_change),
    mean = mean(represent_change),
    se = sd(represent_change) / sqrt(nrow),
    ci = 1.96 * se,
    label = format(round(mean, 2), nsmall = 2)
  ) %>%
  ggplot(., aes(x = full_treatment, y = mean)) +
  geom_pointrange(
    aes(ymin = mean - ci, ymax = mean + ci),
    position = position_dodge(width = .5),
    size = 1,
    linewidth = 1
  ) +
  geom_text(
    aes(x = full_treatment, y = mean - ci, label = label),
    vjust = 1.5,
    size = 3.5
  ) +
  labs(
    y = "Mean Representation Change",
    title = "Representation Rating (0-10)",
    x = "Treatment Condition"
  ) +
  scale_x_discrete(
    labels = c(
      "Control" = "Control",
      "Announce" = "Announce",
      "Credit_Claim" = "Credit\nClaim",
      "Commiserate" = "Commiserate",
      "Protect" = "Protect"
    )
  ) +
  scale_y_continuous(limits = c(-.2, 1.5))

responsible_change_plot_employ <-
  ds %>%
  filter(
    spending_cat %in% c('control', 'employment'),
    !is.na(responsible_change)
  ) %>%
  group_by(full_treatment) %>%
  summarise(
    nrow = length(responsible_change),
    mean = mean(responsible_change),
    se = sd(responsible_change) / sqrt(nrow),
    ci = 1.96 * se,
    label = format(round(mean, 2), nsmall = 2)
  ) %>%
  ggplot(., aes(x = full_treatment, y = mean)) +
  geom_pointrange(
    aes(ymin = mean - ci, ymax = mean + ci),
    position = position_dodge(width = .5),
    size = 1,
    linewidth = 1
  ) +
  geom_text(
    aes(x = full_treatment, y = mean - ci, label = label),
    vjust = 1.5,
    size = 3.5
  ) +
  labs(
    y = "Mean Responsibility Change",
    title = "Responsibility Rating (0-10)",
    x = "Treatment Condition"
  ) +
  scale_x_discrete(
    labels = c(
      "Control" = "Control",
      "Announce" = "Announce",
      "Credit_Claim" = "Credit\nClaim",
      "Commiserate" = "Commiserate",
      "Protect" = "Protect"
    )
  ) +
  scale_y_continuous(limits = c(-.2, 1.5))

combined_mean_plots_employ <-
  therm_change_plot_employ +
  effect_change_plot_employ +
  represent_change_plot_employ +
  responsible_change_plot_employ +
  plot_annotation(
    caption = "NOTE: 95 percent confidence intervals surround point estimates."
  ) &
  theme(plot.caption = element_text(size = 12))

combined_mean_plots_employ
